import router from './index'
import store from '@/store'
// url访问白名单
const whiteList = ['/login']
router.beforeEach(async (to, from, next) => {
  // 开启加载条
  await store.dispatch('page_load_start')
  //路由白名单
  if (whiteList.includes(to.path)) {
    return next()
  }
  // 进入登录页
  if (!store.getters.isLogin) {
    await router.replace('/login')
    return next()
  }
  return next()
})
router.afterEach(async (to, from) => {
  // 关闭加载条
  await store.dispatch('page_load_end')
})
